import crypto from 'node:crypto'

export function randomId() {
  return `${Date.now()}${Math.random().toString().slice(2, -1)}`
}

export function shortRandomId() {
  return (~~(Date.now() / 1000)).toString(36) + Number(Math.random().toString().slice(2, -7)).toString(36)
}

export function createMd5(str: string) {
  return crypto.createHash('md5').update(str).digest('hex')
}
export function createSha1(str: string) {
  return crypto.createHash('sha1').update(str).digest('hex')
}
export function createSha256(str: string) {
  return crypto.createHash('sha256').update(str).digest('hex')
}
export function createSha3(str: string) {
  return crypto.createHash('sha3').update(str).digest('hex')
}
